//
//  PEBatteryClusterCell.m
//  RuiHeAppApp
//
//  Created by Yan Chen on 2023/10/26.
//  能量块 -- 电池簇

#import "RHBatteryClusterChartCell.h"
#import "RHBatteryClusterChartView.h"
#import "RHCellRealDataModel.h"

@interface RHBatteryClusterChartCell()
@property (nonatomic, strong) QMUILabel *titleLab;

@property (nonatomic, strong) RHBatteryClusterChartView *chartView;

@end
@implementation RHBatteryClusterChartCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        [self setupUI];
    }
    return self;
}

- (void)setChartModel:(RHCellRealDataModel *)chartModel{
    _chartModel = chartModel;
    self.titleLab.text = chartModel.title;
    [_chartView setChartModel:_chartModel];
}


-(void)setupUI
{
    kWeakSelf;
    self.contentView.backgroundColor = CFTabViewBgColor;
    UIView *bgView = [[UIView alloc] init];
    [bgView rounded:8 width:1 color:kBorderColor];
    [bgView setBackgroundColor:UIColor.whiteColor];
    [self.contentView addSubview:bgView];
    
    
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.insets(UIEdgeInsetsMake(0, 15, 0, 15));
    }];
    
    QMUILabel *titleLab = [QMUILabel labelWithText:@"--".rh_localized font:kBOLDSYSTEMFONT(16) textColor:kCOLOR_HEX(@"#171A1D")];
    titleLab.numberOfLines = 2;
    titleLab.textAlignment = NSTextAlignmentLeft;
    self.titleLab = titleLab;
    [bgView addSubview:titleLab];
    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.top.mas_offset(15);
       
    }];
    
    
    QMUIButton *fullBtn = [[QMUIButton alloc]init];
    [fullBtn setImage:[UIImage imageNamed:@"kwt_home_arrow"] forState:UIControlStateNormal];
    [bgView addSubview:fullBtn];
    [fullBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.offset(35);
        make.centerY.equalTo(titleLab);
        make.right.mas_offset(-8);
    }];
    [[fullBtn rac_signalForControlEvents:UIControlEventTouchUpInside]subscribeNext:^(__kindof UIControl * _Nullable x) {
       
        if(weakSelf.fullChartBlock){
            weakSelf.fullChartBlock();
        }
    }];
    
    UIView *line = kView;
    line.backgroundColor = kCOLOR_HEX_A(@"#7E868E", 0.16);
    [bgView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_offset(0);
        make.top.equalTo(titleLab.mas_bottom).offset(15);
        make.height.offset(1);
    }];
    
    
    _chartView = [[RHBatteryClusterChartView alloc] initWithFrame:CGRectMake(5, 5,SCREEN_WIDTH-40, 250+130) isLandscape:NO];
    [bgView addSubview:_chartView];
   
    
  
    [_chartView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(line.mas_bottom).offset(10);
        make.left.right.bottom.mas_offset(0);
    }];
}


@end
